package com.bootlever.framework.rocketmq.configuration;

import com.bootlever.framework.rocketmq.properties.RocketmqProperties;
import com.bootlever.framework.rocketmq.templates.RocketmqTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RocketmqConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(RocketmqConfiguration.class);

    @Autowired
    private RocketmqProperties rocketmqProperties;

    @Bean
    @ConditionalOnMissingBean(RocketmqTemplate.class)
    public RocketmqTemplate rocketmqTemplate() {
        logger.info("初始化rocketmq");
        return new RocketmqTemplate(rocketmqProperties);
    }
}
